package cn.anosi.repository.auth;

import java.io.Serializable;
import java.util.List;

import org.springframework.data.jpa.repository.Query;

import cn.anosi.entity.auth.Organization;
import cn.anosi.repository.BaseRepository;
import cn.anosi.vo.OrganizationTree;

public interface OrganizationRepository extends BaseRepository<Organization, Integer>{
	/**
	 * 组织机构树
	 * @return
	 */
	@Query("select new cn.anosi.vo.OrganizationTree(t.id, concat(t.icon,' ',t.name),t.parent.id)  from Organization t where t.isDel = 0")
	public List<OrganizationTree> tree();

	/**
	 * 根据名称查询机构
	 * @param name
	 * @param isDel
	 * @return
	 */
	public Organization findByNameAndIsDel(String name, Integer isDel);

	/**
	 * 查询除当前机构以外的其他机构
	 * @param id
	 * @return
	 */
	public List<Organization> findByIdIsNot(Serializable id);
}
